<template>
  <div>
    <div class="title_box mt-30">
      <p class="title">商标注册信息</p>
      <div class="line"></div>
    </div>

    <div class="mt-16">
      <a-table
        :columns="trademarkInfo"
        :data-source="trademarkData"
        :pagination="trademarkpagination"
        :rowKey="(record) => record.id"
      >
        <a slot="name" slot-scope="text">{{ text }}</a>
        <span slot="brandImage" slot-scope="text, record">
          <img
            width="50"
            v-if="record.attachments"
            :src="getImageUrl(record.attachments)"
            alt=""
          />
          <img width="50" v-else src="@/assets/images/defult_img.png" alt="" />
        </span>
        <span slot="legalStatus" slot-scope="text, record">
          <a-tag v-if="record.legalStatus == 0">申请中</a-tag>
          <a-tag v-else-if="record.legalStatus == 1" color="green">
            已注册
          </a-tag>
          <a-tag v-else-if="record.legalStatus == 2" color="orange">
            已过期
          </a-tag>
        </span>
        <span slot="action"> </span>
      </a-table>
    </div>
  </div>
</template>

<script>
import { getIntellectualList } from "@/apis/com/company";
import { getCookiesUserInfo } from "@/utils/auth";

export default {
  data() {
    return {
      entId: "",
      trademarkpagination: {
        total: 0,
        pageSize: 10,
        current: 1,
        pageSizeOptions: ["10", "20", "30", "40", "50"],
        showTotal: (total) => `共有 ${total} 条数据`,
        showQuickJumper: true,
        showSizeChanger: true,
        onShowSizeChange: (current, pageSize) =>
          this.trademarkonSizeChange(current, pageSize),
        onChange: (page, pageSize) =>
          this.trademarkonPageChange(page, pageSize),
      },
      trademarkData: [],
      trademarkInfo: [
        {
          dataIndex: "index",
          title: "序号",
          customRender: (text, record, index) => `${index + 1}`, // 显示每一行的序
        },
        {
          title: "商标",
          dataIndex: "attachments",
          scopedSlots: { customRender: "brandImage" },
        },
        {
          title: "商标名称",
          dataIndex: "name",
        },
        {
          title: "商标分类",
          dataIndex: "technical",
        },
        {
          title: "申请注册号",
          dataIndex: "patentNumber",
        },
        {
          title: "申请日期",
          dataIndex: "applicationDate",
        },
        {
          title: "获得日期",
          dataIndex: "registrationDate",
        },
        {
          title: "当前状态",
          dataIndex: "legalStatus",
          scopedSlots: { customRender: "legalStatus" },
        },
      ],
    };
  },
  created() {
    this.entId = this.$route.query.id;
  },
  mounted() {
    this.getEntBrandPageList();
  },
  methods: {
    // 商标注册信息  当前页码
    trademarkonSizeChange(page, pageSize) {
      this.trademarkpagination.pageSize = pageSize;
      this.getEntBrandPageList();
    },
    // 商标注册信息   每页条数
    trademarkonPageChange(current, pageSize) {
      this.trademarkpagination.current = current;
      this.getEntBrandPageList();
    },
    //获取企业商标注册信息
    getEntBrandPageList() {
      let _params = {
        pageNum: this.trademarkpagination.current,
        companyId: this.entId,
        pageSize: this.trademarkpagination.pageSize,
        type: 1,
      };
      getIntellectualList(_params)
        .then((res) => {
          console.log("商标注册信息");
          console.log(res);
          if (res.code == 200) {
            this.trademarkData = res.rows;
            this.trademarkpagination.total = res.total;
          }
        })
        .catch((error) => {});
    },
  },
};
</script>

<style lang="less" scoped>
.title_box {
  border-bottom: solid 1px #ebeef5;

  .title {
    font-size: 16px;
    line-height: 14px;
    letter-spacing: 0px;
    color: #303133;
  }

  .line {
    width: 20px;
    height: 4px;
    background-color: #188af1;
    margin-top: 8px;
  }
}
</style>
